// components/mediaItem/mediaItem.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    goods_id: String,
    title: String,
    brief: String,
    desc: String,
    src: String,
    footer: Boolean,
    price: Number,
    swiperStyle: String
  },

  /**
   * 组件的初始数据
   */
  data: {
    count: 1
  },

  /**
   * 组件的方法列表
   */
  methods: {
    /**
     * 添加商品
     */
    bindtapadd() {
      let count = this.data.count
      this.setData({
        count: count + 1
      })
    },
    /**
     * 减少商品
     */
    bindtapminus() {
      let count = this.data.count
      if (count === 1) return
      this.setData({
        count: count - 1
      })
    },
    /**
     * 点击购买按钮跳到购买页面
     */
    bindtapbuy() {
      wx.redirectTo({
        url: '/pages/purchase/pay/pay?id=' + this.data.goods_id + '&count=' + this.data.count
      })
    }
  }
})